package org.duanyu.shopping_admin_service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.duanyu.shopping_common.pojo.Admin;
import org.duanyu.shopping_common.pojo.Permission;

import java.util.List;

@Mapper
public interface AdminMapper extends BaseMapper<Admin> {

    //删除管理员的所有角色
    @Delete("delete from bz_admin_role where aid=#{aid}")
    void deleteAdminRole(Long aid);

    //根据id查询管理员
    Admin findById(Long id);

    //给管理员添加角色
    @Insert("insert into bz_admin_role values (#{aid},#{rid})")
    void addRoleToAdmin(@Param("aid") Long aid,@Param("rid") Long rid);

    //根据用户名查询权限
    List<Permission> findAllPermission(String username);

}
